package com.china.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.china.osourcechina.R;
import com.china.vo.LoginList;

import java.util.List;

/**
 * Created by Administrator on 2016/5/12.
 */
public class LoginListAdapter extends BaseAdapter {

    private List<LoginList> loginlist;
    private Context context;

    public LoginListAdapter(List<LoginList> loginlist, Context context) {
        this.loginlist = loginlist;
        this.context = context;
    }

    @Override
    public int getCount() {
        return loginlist.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null){
            holder = new ViewHolder();
            convertView = convertView.inflate(context, R.layout.adapter_loginlist,null);
            holder.img = (ImageView) convertView.findViewById(R.id.adapter_img);
            holder.title = (TextView) convertView.findViewById(R.id.adapter_title);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        LoginList list = loginlist.get(position);
        holder.img.setImageResource(list.getImage());
        holder.title.setText(list.getUname());
        return convertView;
    }

    class ViewHolder{
        ImageView img;
        TextView title;
    }
}
